package com.justdoit.facedemo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.justdoit.facedemo.domain.Meeting;
import com.justdoit.facedemo.domain.MeetingVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MeetingMapper extends BaseMapper<Meeting> {
    //查询所有的会议
    @Select(" select\n" +
            "meeting_id,user_name,state,conference_theme,content_description,address,start_time,end_time\n" +
            "from\n" +
            "user_table as u\n" +
            "inner join meeting_minutes as m\n" +
            " on\n" +
            " u.user_id = m.user_id\n" +
            " where\n" +
            " user_name like #{user_name} and address like#{address}\n" +
            " limit #{pageNum},#{pageSize};")
    public List<MeetingVo> selectAllMeeting(@Param("user_name") String user_name,@Param("address")String address, @Param("pageNum")Integer pageNum,@Param("pageSize")Integer pageSize );

    //查询所有的会议
    @Select(" select\n" +
            "meeting_id,user_name,state,conference_theme,content_description,address,start_time,end_time\n" +
            "from\n" +
            "user_table as u\n" +
            "inner join meeting_minutes as m\n" +
            " on\n" +
            " u.user_id = m.user_id\n" +
            " where\n" +
            " state = '进行中' \n" +
            " limit 1;")
    public List<MeetingVo> selectOneMeeting();

    //查询总数量
    @Select("select count(*) \n" +
            "from \n" +
            "user_table as u \n" +
            "inner join \n" +
            "meeting_minutes as m \n" +
            "on u.user_id = m.user_id\n" +
            "where u.user_name like #{user_name} and m.address like #{address}")
    public Integer selectTotal(@Param("user_name") String user_name,@Param("address")String address);


}
